home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / DO1002.ARJ / STRINGS.SCR < prev    next >
Text File  |  1991-12-10  |  5KB  |  155 lines

  1. .pg wi full clr
  2. /FRAME ~179 ~196 ~217 ~191 ~192 ~218
  3. /BOX 20 1 60 20
  4. /DRAW V 61 2 21 0 ░
  5. /DRAW H 21 21 61 0 ░
  6. .wi 21 2 59 19
  7.     S T R I N G   F U N C T I O N S
  8. .wi 22 4 58 19
  9. »%t«DO»#« has several functions which allow
  10. you to manipulate strings. These
  11. functions can be used any place
  12. where »wh«variables are expanded»#«.
  13.  
  14. Functions start with '»+ye«@»#«' and take
  15. the general form:
  16. »ye«
  17.  @»cy«{function}({param1},{param1},...)
  18. »#«
  19. .pg 24 clr
  20. »ye«
  21.  @»cy«{function}({param1},{param1},...)
  22. »#«
  23. The »cy«{function}»#«'s are:
  24.  
  25.   »ye«cpy  »gy«=»#« copy part of a string
  26.   »ye«del  »gy«=»#« delete part of a string
  27.   »ye«ins  »gy«=»#« insert one string in
  28.          another string
  29.   »ye«len  »gy«=»#« get the length of a string
  30.   »ye«pos  »gy«=»#« find the position of one
  31.         string in another string
  32.   »ye«trim »gy«=»#« trim unwanted characters
  33.          from the string
  34. .pg clr go 1 5
  35. The following screens present each
  36. of the functions in detail.
  37. /FRAME RESET
  38. .pg -24 wi full clr cy
  39.     FUNCTION NAME»gray«: »%t« CopyString »cy«
  40.  
  41.     ~064cpy({string},{start},{length})
  42. /cw
  43.  
  44. The »%t«CopyString»#« function returns a portion of »cy«{string}»#« starting at
  45. »cy«{start}»#« for a length of »cy«{length}»#«. The following examples are
  46. shown before they are executed. Press »bo«<enter>»#« to execute the
  47. example:
  48.  
  49. |/SET String 1234567890
  50. |This is part of the string: @cpy(%string,2,4).
  51.  
  52. Strings containing commas (",") have to be enclosed in quotes:
  53.  
  54. |This is part of a string: @cpy("Ted, Bill, and I . . .",6,4).
  55.  
  56. .pg wi full clr cy
  57.     FUNCTION NAME»gray«: »%t« DeleteString »cy«
  58.  
  59.     ~064del({string},{start},{length})
  60. /cw
  61.  
  62. The »%t«DeleteString»#« function deletes a portion of »cy«{string}»#« starting
  63. at »cy«{start}»#« for a length of »cy«{length}»#«.  Here are a couple of examples.
  64. Press »bo«<enter>»#« to execute each after you have examined them.
  65.  
  66. |This is part of a string: @del(1234567890,4,2).
  67.  
  68. |/SET Result @del(1234567890,4,3)
  69. |This is the result: %result
  70. .pg wi full clr cy
  71.     FUNCTION NAME»gray«: »%t« InsertString »cy«
  72.  
  73.     ~064ins({string},{target},{position})
  74. /cw
  75.  
  76. Insert »cy«{target}»#« into »cy«{string}»#« before »cy«{position}»#«.
  77.  
  78. Here are some examples:
  79.  
  80. |This is a longer string: @ins(1234567890,»bo«ABC»#«,7)
  81.                               ^   »+re«^»cy«{Position}»#«
  82.  
  83. Notice that the string is inserted »ye«BEFORE »cy«{position}»#« pushing
  84. everything from »cy«{position}»#« to the right.
  85.  
  86. |/SET String DEFG
  87. |Here is %string inserted in another string:  @ins(1234567890,%string,2)
  88. .pg wi full clr cy
  89.     FUNCTION NAME»gray«: »%t« LengthString »cy«
  90.  
  91.     ~064len({string})
  92. /cw
  93.  
  94. Returns the length of »cy«{string}»#«.
  95.  
  96. Here are some examples. Press »bo«<enter>»#« to execute them.
  97.  
  98. |/SET string 1234567890
  99. |Length of %string = @len(%string)
  100.  
  101. The »%t«LengthString»#« function is often  used in conjunction with
  102. other functions:
  103.  
  104. |Here is an example: @del(%string,1,@len(%string)/2)
  105.  
  106. .pg wi full clr cy
  107.     FUNCTION NAME»gray«: »%t« PositionString »cy«
  108.  
  109.     ~064pos({string},{target})
  110. /cw
  111.  
  112. Returns the position of the first occurrence of »cy«{target}»#« in
  113. »cy«{string}»#«.
  114.  
  115. Here are some examples.  Press »bo«<enter>»#« to execute each line.
  116.  
  117. |/set string ABCDEFGHIJK
  118.  
  119. |Position of DEF = @pos(%string,DEF)
  120.  
  121. PositionString, like LengthString is often used in conjunction
  122. with other functions:
  123.  
  124. |/set string test.txt
  125. |Backup file %string = @cpy(%string,1,@pos(%string,"."))BAK
  126.  
  127. .pg wi full clr cy
  128.     FUNCTION NAME»gray«: »%t« TrimString »cy«
  129.  
  130.     ~064trim{string},{target},L|R|B)
  131. /cw
  132.     Removes unwanted characters (»cy«{target}»#«) from the »wh«end»#«(s) of
  133.     »cy«{string}»#«.
  134.  
  135.     »cy«{target}»#« is evaluated »gr«AS IS»#«. That is "»wh«a»#«" is diffent from "»wh«A»#«".
  136.     »cy«L »gy«=»#« Trims the start of the string (»wh«left»#«)
  137.     »cy«R »gy«=»#« Trims the end of the string (»wh«right»#«)
  138.     »cy«B »gy«=»#« Trims »wh«both ends»#« of the string.
  139. .pg clr
  140.     Here are some examples.  Press »bo«<enter>»#« to execute each.
  141.  
  142. |/set string "  abcdeABCDEabcde  "
  143.     »cy«Original String [»wh«%string»cy«]»#«
  144. |    [@trim(%string," abde",B)]
  145. |    [@trim(%string," ",L)]
  146. |    [@trim(%string," e",R)]
  147. |    [@trim(%string," E",R)]
  148.         Notice that "»ye«E»#«" gives different results than "»ye«e»#«"
  149. |/SET string2 @trim(@trim(%string," ",B),"abcdefghijklmnopqrstuvwxyz",b)
  150.     [%string2]
  151.         The first »%t«TrimString»#« function removes »wh«spaces»#«.  The second
  152.         function removes all »wh«lower case letters»#«.
  153.         Notice that »re«CAPITAL»#« letters are not removed.
  154. /ENDEXEC CLEAR
  155.